package singleStackProgrammingQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("POST")
        url("/api/single-stack-programming-quiz")
        headers {
            contentType(applicationJsonUtf8())
            header("id", 1)
        }
        body("""
            {
                "definitionRepo":"https://github.com/test/test",
                "title":"java",
                "tags":["java","go"],
                "stackId":1,
                "remark":"remark",
                "quizGroupId":1,
                "makerId":1
            }
        """)
        bodyMatchers {
            jsonPath('$.definitionRepo', byRegex("[\\s\\S]+"))
            jsonPath('$.title', byRegex("[\\s\\S]+"))
            jsonPath('$.tags', byRegex("[\\s\\S]+"))
            jsonPath('$.stackId', byRegex(number()))
            jsonPath('$.remark', byRegex("[\\s\\S]+"))
            jsonPath('$.quizGroupId', byRegex(number()))
            jsonPath('$.makerId', byRegex(number()))
        }
    }
    response {
        status(201)
        headers {
            contentType(applicationJsonUtf8())
        }
        body("""
        {
            "uri":"/api/v3/homeworkQuizzes/1",
            "id":1
        }
        """)
        bodyMatchers {
            jsonPath('$.uri', byRegex("[\\s\\S]+"))
            jsonPath('$.id', byRegex(number()))
        }
    }
}
